<template>
  <div v-loading="loading">
    <el-upload
      class="upload-demo upload"
      drag
      action="http://localhost:8181/excel/postele"
      multiple
      :on-success="handleAvatarSuccess"
      :on-progress="handleprogress"
    >
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">
        将文件拖到此处，或
        <em>点击上传</em>
      </div>
      <div class="el-upload__tip" slot="tip">只能上传xlsx文件，且不超过500kb</div>
    </el-upload>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loading: false
    };
  },
  methods: {
    handleprogress() {
      this.loading = true;
    },
    handleAvatarSuccess(res, file, fileList) {
      if (res == "success")
        this.$alert("用户以批量添加！", "操作成功", {
          confirmButtonText: "确定",
          callback: action => {
            this.$router.push("/index_manager/costhead");
          }
        });
      else console.log("error:::" + res);
    }
  },
  components: {}
};
</script>

<style scoped>
.upload {
  margin: auto;
  width: 50%;
}
</style>
